package io.renren.modules.integral.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.integral.dao.IntegralHistoryDao;
import io.renren.modules.integral.entity.IntegralHistoryEntity;
import io.renren.modules.integral.service.IntegralHistoryService;


@Service("integralHistoryService")
public class IntegralHistoryServiceImpl extends ServiceImpl<IntegralHistoryDao, IntegralHistoryEntity> implements IntegralHistoryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String sea = (String)params.get("sea");
        String date=(String)params.get("dateTime");
        String[] d;
        EntityWrapper<IntegralHistoryEntity>  ew= new EntityWrapper<IntegralHistoryEntity>();
        ew.like(StringUtils.isNotBlank(sea),"user_id", sea)
                .or()
                .like(StringUtils.isNotBlank(sea),"name", sea)
                .or()
                .like(StringUtils.isNotBlank(sea),"phone", sea);
        if(date!=null) {
          d=  date.split(" - ");
            ew.between("create_time", d[0],d[1]);
        }

        Page<IntegralHistoryEntity> page = this.selectPage(
                new Query<IntegralHistoryEntity>(params).getPage(),ew

        );

        return new PageUtils(page);
    }

}
